package com.wnx.action;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.wnx.db.SaleDao;
import com.wnx.entity.GoodsPager;

public class SearchAction extends ActionSupport {
	private int page=1;
	private String search;
	
	public String getSearch() {
		return search;
	}
	public void setSearch(String search) {
		this.search = search;
	}
	public int getPage() {
		return page;
	}
	public void setPage(int page) {
		this.page = page;
	}
	public String execute() throws Exception{
		
		if(page<0){
			page=1;
		}
		
		SaleDao sd = new SaleDao();
		GoodsPager g = sd.getGoodsByPagerSearch(page-1, this.search);
		Map<String, Object> session = ActionContext.getContext().getSession();
		session.put("g", g);
		return SUCCESS;
	}
}
